<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>智能家居控制系统</title>
    <style>
        :root {
            --primary-color: #4facfe;
            --glass-bg: rgba(255, 255, 255, 0.2);
            --glass-border: rgba(255, 255, 255, 0.3);
            --text-color: #666;
        }

        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            background: url('333.png') center/cover no-repeat fixed;
            font-family: 'Microsoft YaHei', sans-serif;
            min-height: 100vh;
        }

        .dashboard {
            width: 400px;
            background: var(--glass-bg);
            border-radius: 12px;
            backdrop-filter: blur(10px);
            border: 1px solid var(--glass-border);
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            padding: 25px;
            margin: 20px;
        }

        .title {
            font-size: 1.5em;
            text-align: center;
            color: #333;
            margin-bottom: 25px;
        }

        .control-panel {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

       

        .control-label {
            color: #333;
            font-size: 16px;
            margin-bottom: 12px;
        }

        /* 操作模式样式 */
        .mode-container {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .mode-switch {
            position: relative;
            width: 60px;
            height: 30px;
        }

        .mode-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .mode-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            transition: .4s;
            border-radius: 34px;
        }

        .mode-slider:before {
            position: absolute;
            content: "";
            height: 22px;
            width: 22px;
            left: 4px;
            bottom: 4px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }

        .mode-switch input:checked+.mode-slider {
            background-color: var(--primary-color);
        }

        .mode-switch input:checked+.mode-slider:before {
            transform: translateX(30px);
        }

        .mode-text {
            font-size: 14px;
            color: var(--text-color);
            transition: color 0.3s;
            margin-left: 8px;
        }

        /* 其他设备样式 */
        .switch-container {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .device-switch {
            position: relative;
            width: 60px;
            height: 30px;
        }

        .device-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .device-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            transition: .4s;
            border-radius: 34px;
        }

        .device-slider:before {
            position: absolute;
            content: "";
            height: 22px;
            width: 22px;
            left: 4px;
            bottom: 4px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }

        .device-switch input:checked+.device-slider {
            background-color: var(--primary-color);
        }

        .device-switch input:checked+.device-slider:before {
            transform: translateX(30px);
        }

        .status-text {
            font-size: 14px;
            color: var(--text-color);
            transition: color 0.3s;
            margin-left: 8px;
        }

        .status-text.active {
            color: var(--primary-color);
        }

        .ac-controls {
            display: flex;
            gap: 20px;
        }

        .ac-switch {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        input[type="text"] {
            width: 100%;
            height: 40px;
            padding: 0 10px;
            border: 1px solid rgba(0, 0, 0, 0.1);
            border-radius: 5px;
            background: rgba(255, 255, 255, 0.9);
            font-size: 14px;
        }
        .nav-links {
            display: flex;
            justify-content: space-between;
            margin-top: 25px;
            padding-top: 15px;
            border-top: 1px solid rgba(255, 255, 255, 0.2);
        }

        .nav-links a {
            color: var(--text-color);
            text-decoration: none;
            font-size: 14px;
            transition: color 0.3s;
        }

        .nav-links a:hover {
            color: #333;
        }
    </style>
    <script>
        // 设备开关控制
        function toggleDevice(deviceType, element) {
            const statusElement = document.getElementById(`${deviceType}-status`);
            statusElement.textContent = element.checked ? '开启' : '关闭';
            statusElement.classList.toggle('active', element.checked);

            const cmdMap = {<!-- 命令映射表 -->
                'refresh_update': [0, 1],
                'regular_update': [1, 1],
                'change_update': [2, 1],
            };
            const [cmd1, cmd2] = cmdMap[deviceType];
            console.log(`cmd1=${cmd1}&cmd2=${element.checked? 1 : 0}`);
            sendCommand(`cmd1=${cmd1}&cmd2=${element.checked ? 1 : 0}`);
        }
        // 发送命令
        function sendCommand(cmd) {
            const xhr = new XMLHttpRequest();
            xhr.open("POST", "YOUR_API_ENDPOINT", true);
            xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xhr.send(cmd);
            console.log("发送指令:", cmd);
        }
    </script>
</head>

<body>
    <div class="dashboard">
        <h1 class="title">智能家居控制系统</h1>
        <div class="control-panel">        
            <!-- 安全警报 -->
            <div class="control-group">
                <div class="control-label">刷新时更新数据</div>
                <div class="switch-container">
                    <label class="device-switch">
                        <input type="checkbox" id="refresh_update" onchange="toggleDevice('refresh_update', this)">
                        <span class="device-slider"></span>
                    </label>
                    <span class="status-text" id="refresh_update-status">关闭</span>
                </div>
            </div>
            <!-- 窗帘控制 -->
            <div class="control-group">
                <div class="control-label">定时更新数据</div>
                <div class="switch-container">
                    <label class="device-switch">
                        <input type="checkbox" id="regular_update" onchange="toggleDevice('regular_update', this)">
                        <span class="device-slider"></span>
                    </label>
                    <span class="status-text" id="regular_update-status">关闭</span>
                </div>
            </div>
            <!-- 喷淋系统 -->
            <div class="control-group">
                <div class="control-label">变化时更新数据</div>
                <div class="switch-container">      
                    <label class="device-switch">
                        <input type="checkbox" id="change_update" onchange="toggleDevice('change_update', this)">
                        <span class="device-slider"></span>
                    </label>
                    <span class="status-text" id="change_update-status">关闭</span>
                </div>
            </div>

            <div class="nav-links">
                <a href="mainpage.html">主页</a>
                <a href="stm32.html">STM32</a>
                <a href="modbusslave.html">Modbus Slave</a>
                <a href="modeselect.html">模式选择</a>
                <a href="http://192.168.43.241:8080/stream_simple.html">视频监控</a>
            </div>
        </div>
    </div>
</body>

</html>